#include "Disk.h"
#include "BlockLinkedList.h"
#include "FSBlock.h"
#include "BlockGroup.h"
#include "FreeList.h"
#include "DirectoryEntry.h"
#include "Directory.h"
#include "File.h"

#include <stdio.h>
#include <stdlib.h>// atoi

#define MAX_BLOCK_GROUPS 4

int main(int argc, char **argv) {
        unsigned long numberOfBlocks;
        unsigned int blockSize;
        int testCase = 5;

        switch (testCase) {
        case 0:
                Disk::GetSizes("/dev/sda6", numberOfBlocks, blockSize);
                printf("numberOfBlocks= %lu, blockSize= %u\n", numberOfBlocks, blockSize);
                break;
        case 1:
                Disk::GetSizes("/dev/disk0s3", numberOfBlocks, blockSize);
                printf("numberOfBlocks= %lu, blockSize= %u\n", numberOfBlocks, blockSize);
                break;

        case 2:
                Disk::Test();
                break;

        case 3:
                BlockLinkedList::Test();
                break;
    
        case 4: // FreeList & BlockGroup web site testing
                if (argc < 3) {
                        printf("Usage: main BinaryFileSystemName StartBlockNumber1 ... \n");
                        printf("    (actual number of arguments was %d)", argc);
                } else {
                        char *filename = argv[1];
                        // An array of block numbers
                        int StartBlockNumber[MAX_BLOCK_GROUPS]; 
                        int i;
                        for (i=2; i < argc; i++) {
                            StartBlockNumber[i-2] = atoi(argv[i]);
                        }
                        StartBlockNumber[i-2] = 0;
                                                         
                        printf("filename= %s\n", argv[1]);
                        for (i=0;; i++) {
                            if (StartBlockNumber[i] == 0) break;
                            printf("StartBlockNumber= %d\n",StartBlockNumber[i]);
                        }
                        
                        FreeList::Test(false, filename, StartBlockNumber);
                        // FreeList::Test(false, "disk1", 1);
                }

        case 5:
                FreeList::Test();
                break; 

        case 6: // Directory, FreeList & BlockGroup web site testing
                if (argc != 2) {
                        printf("Usage: main BinaryFileSystemName\n");
                } else {
                        Directory::WebTest(argv[1]);
                }
                break;

        case 7:
                Directory::Test();
                break;
        case 8:
          File::Test();
        break;

        }

}


